package com.house.tgroup.controller;

import com.aliyun.oss.internal.OSSUtils;
import com.house.tgroup.util.OssUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.house.tgroup.entity.GroupEntity;
import com.house.tgroup.service.GroupService;
import com.house.common.utils.R;
import org.springframework.web.multipart.MultipartFile;


/**
 * 
 *
 * @author wzh
 * @email sunlightcs@gmail.com
 * @date 2022-04-27 17:35:02
 */
@RestController
@RequestMapping("tgroup/group")
public class GroupController {
    @Autowired
    private GroupService groupService;
    @Autowired
    private OssUtils ossUtils;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam String name){
     return groupService.getlist(name);
    }


    @RequestMapping("/save")
    public R save(@RequestBody GroupEntity groupEntity){
     groupService.save(groupEntity);
     return R.ok();
    }


    @DeleteMapping("/delete/{id}")
    public R deleteById(@PathVariable("id")Integer id){
        groupService.removeById(id);

        return R.ok();
    }


    @PostMapping("/upload")
    public R upload(@RequestParam MultipartFile file){
        return ossUtils.uploadFile(file);
    }

}
